package com.cxlin.cwanandroid.model.repository

import com.cxlin.base.model.api.BaseRepository
import com.cxlin.cwanandroid.model.api.WanRetrofitClient
import com.cxlin.cwanandroid.model.bean.User
import com.cxlin.base.model.api.Result

/**
 *
 * @Author: chenxunlin
 * @Date: 2024/4/29 14:02
 */
class LoginRepository : BaseRepository() {

    suspend fun login(userName: String, passWord: String): Result<User> {
        return safeApiCall(
            call = { executeResponse(WanRetrofitClient.service.login(userName, passWord)) },
            errorMessage = ""
        )
    }

    suspend fun register(userName: String, passWord: String): Result<User> {
        return safeApiCall(
            call = {
                executeResponse(
                    WanRetrofitClient.service.register(
                        userName,
                        passWord,
                        passWord
                    )
                )
            },
            errorMessage = ""
        )
    }
}